package com.rxjava.rxjava;

import java.util.Random;

import com.google.gson.Gson;

import rx.Observable;
import rx.Observer;

public class RxJavaTest {
	public static void main(String[] args) throws InterruptedException {
		User user = new User();
		user.setAddress("1111");
		user.setName("2222");
		UserCache.next(user);
		UserCache.getInstance().subscribe(s -> System.out.println(new Gson().toJson(s)));
		
		for (int i = 0; i < 10; i++) {
			Thread.sleep(new Random().nextInt(5000));
			new Thread(()->{
				user.setAddress(new Random().nextInt()+"");
				user.setName(new Random().nextInt()+"");
				UserCache.next(user);
			}).start();
		}
	}
	

}
